<?php 
 include_once dirname(__FILE__)."/config.php";
 class phase_desc_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_id_phase_desc;
		 protected $_titre;
		 protected $_description;
		 protected $_type_envoi;
		 public function get_name_table(){ return "phase_desc";}
		 public function get_name_id_phase_desc(){ return "id_phase_desc";}
		 public function get_name_titre(){ return "titre";}
		 public function get_name_description(){ return "description";}
		 public function get_name_type_envoi(){ return "type_envoi";}
		 public function set_id_phase_desc($parametre){  $this->_id_phase_desc=$parametre;}	
		 public function set_titre($parametre){  $this->_titre=$parametre;}	
		 public function set_description($parametre){  $this->_description=$parametre;}	
		 public function set_type_envoi($parametre){  $this->_type_envoi=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_id_phase_desc(){ return $this->_id_phase_desc;}
		 public function get_titre(){ return $this->_titre;}
		 public function get_description(){ return $this->_description;}
		 public function get_type_envoi(){ return $this->_type_envoi;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 phase_desc(
			titre,
			description,
			type_envoi)
 VALUES(
			'".$this->_titre."',
			'".$this->_description."',
			'".$this->_type_envoi."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_titre)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
titre='".$this->_titre."'";
}
if(!empty($this->_description)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
description='".$this->_description."'";
}
if(!empty($this->_type_envoi)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
type_envoi='".$this->_type_envoi."'";
}
$sql="UPDATE 
phase_desc SET 
 ".$sql."
								WHERE id_phase_desc ='".$this->_id_phase_desc."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
phase_desc 
 
									WHERE id_phase_desc ='".$this->_id_phase_desc."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
phase_desc ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		id_phase_desc,
		titre,
		description,
		type_envoi
 FROM 
 phase_desc";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_id_phase_desc=$row->id_phase_desc;
		$this->_titre=$row->titre;
		$this->_description=$row->description;
		$this->_type_envoi=$row->type_envoi;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>